package tripmaker.util

object ObjectToString {
  object Str { def unapplySeq(s: String): Option[Seq[Char]] = Some(s) }
}

import ObjectToString._

trait ObjectToString {
  def id = getClass.getSimpleName.split("\\$").last
  
  override def toString = splitCamelCase(id)

  def splitCamelCase(str: String) =
    String.valueOf(
      (str + "A" * 2) sliding (3) flatMap {
        case Str(a, b, c) =>
          (a.isUpper, b.isUpper, c.isUpper) match {
            case (true, false, _) => " " + a
            case (false, true, true) => a + " "
            case _ => String.valueOf(a)
          }
      } toArray
    ).trim
}